<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<!--<link rel="stylesheet" href="https://act.weixin.qq.com/static/cdn/css/wepayui/0.1.1/wepayui.min.css">-->
<link rel="stylesheet" href="/css/pay.css">
<link rel="stylesheet" href="/css/keyboard.css">
<title>懒人手礼无人货架</title>
</head>
    <body>
        <div class="pay-top">
            <div class="pay-shop-info">
                <div class="content">
                    <span class="shop-name">懒人手礼无人货架</span>
                </div>
            </div>
            <div class="pay-input-money">
                <div class="input-left">
                    <span>输入消费金额</span>
                </div>
                <div class="input-right">
                    <span>￥</span>
                    <label id="paymoney" type="text"></label>
                </div>
            </div>
            <div class="upper-case">
                <span class="upper-case-content"></span>
            </div>
        </div>
        <div class="payinfo">
            <table cellspacing="0" cellpadding="0">
                <tr>
                    <td class="paynum">1</td>
                    <td class="paynum">2</td>
                    <td class="paynum">3</td>
                    <td id="pay-return">
                        <div class="keybord-return"></div>
                    </td>
                </tr>
                <tr>
                    <td class="paynum">4</td>
                    <td class="paynum">5</td>
                    <td class="paynum">6</td>
                    <td rowspan="3" class="pay">
                        <a href="javascript:return false;">
                            <div class="a-pay">
                                <p>确认</p>
                                <p>支付</p>
                            </div>
                        </a>
                    </td>
                </tr>
                <tr>
                    <td class="paynum">7</td>
                    <td class="paynum">8</td>
                    <td class="paynum">9</td>
                </tr>
                <tr>
                    <td id="pay-zero" colspan="2" class="payzero">0</td>
                    <td id="pay-float">.</td>
                </tr>
            </table>
        </div>

        <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
        <script src="/lib/jquery-2.1.4.js"></script>
        <script type="text/javascript">
            var openid = "<%= docs.openid %>";
            var mid = "<%= docs.mid %>";
            var jssdk = <%- JSON.stringify(docs.jssdk) %>;
            jssdk.jsApiList = ["chooseWXPay"];
            wx.config(jssdk);
            wx.ready(function(){
                $("button").click(function(){
                    $.ajax({
                        type: "post",
                        dataType: "json",
                        data: {
                            mid : mid,
                            openid : openid,
                            money : $("#money").val(),
                            timestamp : jssdk.timestamp
                        },
                        url: "/pay",
                        success: function(data){
                            var params = data.docs;
                            var oid = params.oid;
                            var pay = params.pay;
                            params.pay.success = function(res){
                                var form = $("<form action='open/order' method='post'><input name='oid' value='"+oid+"' /></form>");
                                form.submit();
                            };
                            wx.chooseWXPay(pay);
                        }
                    });
                });
            });
        </script>
    </body>
</html>
